<script setup lang="ts">
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import type { Doctor } from '@/types/doctor'
import { getDoctor } from '@/services/doctor'

const doctor = ref<Required<Doctor>>()

onLoad(async (query) => {
  if (query?.id) {
    doctor.value = await getDoctor(query?.id)
  }
})
</script>

<template>
  <view class="container" v-if="doctor">
    <view class="my-doctor-container">
      <!-- 头像和昵称区域 -->
      <view class="top-box">
        <image :src="doctor.photoFront" class="avatar"></image>
        <view class="nickname">{{ doctor.name }}</view>
      </view>

      <!-- 面板区域 -->
      <view class="panel-list">
        <!-- 第1个面板 -->
        <view class="panel">
          <view class="panel-title">
            医生信息
          </view>
          <view class="panel-body">
            <uni-table border stripe emptyText="暂无更多数据">
              <!-- 表头行 -->
              <uni-tr>
                <uni-th align="left" width="90">姓名</uni-th>
                <uni-th align="left">{{ doctor.name }}</uni-th>
              </uni-tr>
              <!-- 表格数据行 -->
              <!-- <uni-tr>
              <uni-td>姓名</uni-td>
              <uni-td>{{doctor.name}}</uni-td>
            </uni-tr> -->
              <uni-tr>
                <uni-td>性别</uni-td>
                <uni-td>{{ doctor.sex === 1 ? '男' : '女' }}</uni-td>
              </uni-tr>
              <uni-tr>
                <uni-td>年龄</uni-td>
                <uni-td>{{ doctor.age }}</uni-td>
              </uni-tr>
              <uni-tr>
                <uni-td>学位</uni-td>
                <uni-td>{{ doctor.degree }}</uni-td>
              </uni-tr>
              <uni-tr>
                <uni-td>职称</uni-td>
                <uni-td>{{ doctor.position }}</uni-td>
              </uni-tr>
              <uni-tr>
                <uni-td>科室</uni-td>
                <uni-td>{{ doctor.sectionOffice }}</uni-td>
              </uni-tr>
              <uni-tr>
                <uni-td>专长</uni-td>
                <uni-td>{{ doctor.specialty }}</uni-td>
              </uni-tr>
              <uni-tr>
                <uni-td>就职医院</uni-td>
                <uni-td>{{ doctor.hospital }}</uni-td>
              </uni-tr>
              <uni-tr>
                <uni-td>临床经验</uni-td>
                <uni-td>{{ doctor.clinicalExperience }}</uni-td>
              </uni-tr>
            </uni-table>
          </view>
        </view>
      </view>
    </view>

    <button @click="" type="primary">沟通</button>
  </view>
</template>

<style lang="scss">
.container {
  button {
    line-height: 2;
    font-size: 16px;
    background-color: #00e676;
    position: fixed;
    bottom: 5px;
    left: 20px;
    right: 10px;
    border-radius: 20px;
  }
}

.my-doctor-container {
  padding-bottom: 45px;
  height: 100%;
  // background-color: #F4F4F4;

  .top-box {
    height: 400rpx;
    background-color: $themeColor;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;

    .avatar {
      background-color: #FFFFFF;
      width: 90px;
      height: 90px;
      border-radius: 45px;
      border: 2px solid #FFF;
      box-shadow: 0 1px 5px black;
    }

    .nickname {
      font-size: 16px;
      color: #FFF;
      font-weight: bold;
      margin-top: 10px;
    }
  }
}

.panel-list {
  padding: 0 10px;
  position: relative;
  top: -10px;

  .panel {
    background-color: white;
    border-radius: 3px;
    margin-bottom: 8px;

    .panel-title {
      line-height: 45px;
      padding-left: 10px;
      font-size: 15px;
      // border-bottom: 1px solid #F4F4F4;
    }

    .panel-body {
      display: flex;
      justify-content: center;

      .panel-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: space-around;
        padding: 10px 0;
        font-size: 13px;

        .icon {
          width: 35px;
          height: 35px;
        }
      }
    }
  }
}

.panel-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  padding: 0 10px;
  line-height: 45px;
}
</style>
